#include <jni.h>
#include <string>
#include <android/log.h>
#include <queue>
#include <cmath>
#include <stdlib.h>
#include <BST.hpp>

using namespace std;

void visit(int key, int value) {
    __android_log_print(ANDROID_LOG_ERROR, "TAG", "key= %d, value= %d", key, value);
}

extern "C"
JNIEXPORT jstring
JNICALL
Java_com_ndk_day42_MainActivity_stringFromJNI(
        JNIEnv *env,
        jobject /* this */) {

    AVL<int, int> *avl = new AVL<int, int>();
    avl->put(3, 3);
    avl->put(2, 2);
    avl->put(1, 1);
    avl->put(4, 4);
    avl->put(5, 5);
    // 6,7,10, 9,8  // 层序输出：4,2,7,1，3,6,9,5,8,10

    avl->remove(3);
    avl->remove(1);
    avl->levelTraverse(visit); // 层序遍历。传递visit函数进去打印。

    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());
}

